package copyengine.sceneAndDialog.dialog.animation
{
    import com.greensock.TweenMax;

    import copyengine.sceneAndDialog.dialog.ICEDialog;
    import copyengine.utils.CECallbackFunction;

    public class CEDialogAlphaFadeInOutAnimation implements ICEDialogAnimation
    {
        private var mDialog:ICEDialog;
        private var mShowFinishCallback:CECallbackFunction;
        private var mHideFinishCallback:CECallbackFunction;

        public function CEDialogAlphaFadeInOutAnimation()
        {
        }

        public function set dialog(_dialog:ICEDialog):void {mDialog = _dialog;}

        public function playShowAnimation(_finishCallback:CECallbackFunction):void
        {
            mShowFinishCallback = _finishCallback;
            mDialog.dialogContainer.alpha = 0;
            TweenMax.to(mDialog.dialogContainer, 0.3, {
                alpha: 1,
                onComplete: function ():void {mShowFinishCallback.isEnable && mShowFinishCallback.callback()}
            })
        }

        public function playCloseAnimation(_finishCallback:CECallbackFunction):void
        {
            mHideFinishCallback = _finishCallback;
            TweenMax.to(mDialog.dialogContainer, 0.3, {
                alpha: 0,
                onComplete: function ():void {mHideFinishCallback.isEnable && mHideFinishCallback.callback()}
            })
        }

        public function dispose():void
        {
        }
    }
}
